package com.szgr.baoyin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.szgr.baoyin.R;
import com.szgr.baoyin.model.RedPacket;
import com.szgr.baoyin.utils.ViewFindUtils;

import java.util.List;

/**
 * Created by yang on 15/12/4.
 */
public class RedPacketListAdapter extends BaseAdapter {
    private Context mContext;
    private List<RedPacket> data;
    public RedPacketListAdapter(Context context, List<RedPacket> data){
        mContext = context;
        this.data = data;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_red_packet_list_view,parent,false);
        }

        RedPacket redPacket = data.get(position);
        TextView tv_price = ViewFindUtils.hold(convertView, R.id.red_price);
        TextView tv_minus = ViewFindUtils.hold(convertView, R.id.red_minus);
        TextView tv_name = ViewFindUtils.hold(convertView, R.id.red_name);
        TextView tv_desc = ViewFindUtils.hold(convertView, R.id.red_desc);
        TextView tv_date = ViewFindUtils.hold(convertView,R.id.red_date);

        tv_price.setText("¥ " + redPacket.getVoucher_price());
        tv_minus.setText("满" + redPacket.getVoucher_limit() + "使用");
        tv_name.setText(redPacket.getVoucher_title());
        tv_desc.setText(redPacket.getVoucher_desc());
        tv_date.setText(redPacket.getDesc());

        return convertView;
    }
}
